﻿/// <reference name="MicrosoftAjax.js" />
/// <reference path="file://C:/SharePoint Hive/TEMPLATE/LAYOUTS/SP.UI.Dialog.debug.js" />
/// <reference path="file://C:/SharePoint Hive/TEMPLATE/LAYOUTS/SP.Core.debug.js" />
/// <reference path="file://C:/SharePoint Hive/TEMPLATE/LAYOUTS/SP.Runtime.debug.js" />
/// <reference path="file://C:/SharePoint Hive/TEMPLATE/LAYOUTS/SP.debug.js" />

Type.registerNamespace("CKSAS.Samples.AppStorage");

// Constructor function for DialogHelper class
CKSAS.Samples.AppStorage.DialogHelper = function() {
    CKSAS.Samples.AppStorage.DialogHelper.initializeBase(this);
};

// DialogHelper class definition
CKSAS.Samples.AppStorage.DialogHelper.prototype = {
    // initialization function for the DialogHelper class
    init: function () {
    },

    // Opens the provided page in a dialog window
    OpenPage: function (relativePageUrl, pageTitle) {
        var absoluteUrl = SP.Utilities.Utility.getLayoutsPageUrl(relativePageUrl);

        // dialog options
        var dialogOptions = {
            url: absoluteUrl,
            allowMaximize: false,
            allowMinimize: false,
            autoSize: true,
            title: pageTitle
        };

        SP.UI.ModalDialog.showModalDialog(dialogOptions);
    }
};

// Gets the default instance of the DialogHelper class
CKSAS.Samples.AppStorage.DialogHelper.get_instance = function () {
    if (!CKSAS.Samples.AppStorage.DialogHelper.instance) {
        CKSAS.Samples.AppStorage.DialogHelper.instance = new CKSAS.Samples.AppStorage.DialogHelper();
    }
    
    return CKSAS.Samples.AppStorage.DialogHelper.instance;
};

// register class for usage
CKSAS.Samples.AppStorage.DialogHelper.registerClass("CKSAS.Samples.AppStorage.DialogHelper");

// notify SOD infrastructure
SP.SOD.notifyScriptLoadedAndExecuteWaitingJobs("CKSAS.Samples.AppStorage.DialogHelper.js");
